package com.abcd.godating.utils;

import java.util.Collection;
import java.util.HashSet;

import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.User;

import com.abcd.godating.domain.Account;

public class SecurityUtils {
	public static void signin(Account account) {
		GrantedAuthority grantedAuthority = new SimpleGrantedAuthority(account
				.getRole().name());
		Collection<GrantedAuthority> authorities = new HashSet<GrantedAuthority>(
				1);
		authorities.add(grantedAuthority);
		SecurityContextHolder.getContext().setAuthentication(
				new UsernamePasswordAuthenticationToken(new User(account
						.getId() + "", "notPwd", authorities), null,
						authorities));
	}
}
